import java.util.ArrayList;

/**
   This class models a sentence.
*/
public class Sentence
{
   private ArrayList<String> words = new ArrayList<String>();

   /**
      Construct a sentence with a given text. 
      @param text the sentence. The text ends in a 
      punctuation mark which is not stored.
   */
   public Sentence(String text) 
   { 
      // your work here
      String str[] = text.split(" ");
      for(int i = 0; i < str.length; i++)
      {
         words.add(str[i]);
      }
   }

   /**
      Get the ith word in the sentence.
      @return the ith word
   */
   public String getWord(int i) 
   {
      // your work here
      String str = words.get(i);
      str = str.substring(0, str.length() - 1);
      return str;
   }

   /**
      Get the number of words in the sentence.
      @return the number of words
   */
   public int getCount() 
   {
      // your work here
      return words.size();
   }   
 
   // This method is used for checking your work. Do not modify it

   public static String check(String sent)
   {
      Sentence aSentence = new Sentence(sent);
      return aSentence.getWord(aSentence.getCount() - 1);
   }
}